/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cardarus.operatingsystem.domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

/**
 * This class represents a certificate.
 *
 * @author Daqi
 */
@Entity
public class Certificate implements Serializable {
    /**
     * Certificate Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    private double denomination;

    /**
     * Customer associated with this card
     */
    @ManyToOne
    private Customer customer;

    /**
     * Card issued date
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date emission;

    /**
     * Expire date of the card
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date expiration;
    /**
     * Minimum purchase
     */
    private double minimumPurchase;
    /**
     * Status of Card used/Not used
     */
    private boolean used;
    /**
     * Sales transactions associated with this card
     */
    
    @OneToOne(mappedBy = "certificate")
    private SalesTransaction salesRecord;

    public Certificate() {
    }

    public Certificate(double denomination, Customer customer, Date emission, Date expiration, double minimumPurchase) {
        this.denomination = denomination;
        this.customer = customer;
        this.emission = emission;
        this.expiration = expiration;
        this.minimumPurchase = minimumPurchase;
    }

    
    /**
     * Returns card Id
     * @return 
     */
    public int getId() {
        return id;
    }
    /**
     * Sets card id
     * @param id
     */
    public void setId(int id) {
        this.id = id;
    }
    /**
     * @return the denomination
     */
    public double getDenomination() {
        return denomination;
    }

    /**
     * @param value
     */
    public void setDenomination(double value) {
        this.denomination = value;
    }

    /**
     * @return the customer
     */
    public Customer getCustomer() {
        return customer;
    }

    /**
     * @param customer the customer to set
     */
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    /**
     * @return the emission
     */
    public Date getEmission() {
        return emission;
    }

    /**
     * @param emission the emission to set
     */
    public void setEmission(Date emission) {
        this.emission = emission;
    }

    /**
     * @return the expiration
     */
    public Date getExpiration() {
        return expiration;
    }

    /**
     * @param expiration the expiration to set
     */
    public void setExpiration(Date expiration) {
        this.expiration = expiration;
    }

    /**
     * @return the minimumPurchase
     */
    public double getMinimumPurchase() {
        return minimumPurchase;
    }

    /**
     * @param minimumPurchase the minimumPurchase to set
     */
    public void setMinimumPurchase(double minimumPurchase) {
        this.minimumPurchase = minimumPurchase;
    }

    /**
     * @return the used
     */
    public boolean isUsed() {
        return used;
    }

    /**
     * @param used the used to set
     */
    public void setUsed(boolean used) {
        this.used = used;
    }

    /**
     * @return the salesRecord
     */
    public SalesTransaction getSalesRecord() {
        return salesRecord;
    }

    /**
     * @param salesRecord the salesRecord to set
     */
    public void setSalesRecord(SalesTransaction salesRecord) {
        this.salesRecord = salesRecord;
    }

}
